﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class T_LoginSys
    {
        SqlConnection Conn = new SqlConnection("Data Source=.;Initial Catalog=Hospitalsystem;Integrated Security=True");
        public MODEL.T_LoginSys LoginXin(string T_LoginSName, string T_LoginSPwd)
        {
            try
            {
                if (Conn.State == ConnectionState.Closed)
                    Conn.Open();
                MODEL.T_LoginSys md = new MODEL.T_LoginSys();
                string sql = "select * from T_LoginSys where T_LoginSName='"+T_LoginSName+"' and T_LoginSPwd='"+T_LoginSPwd+"'";
                SqlCommand Cmd = new SqlCommand(sql,Conn);
                SqlDataAdapter adapter = new SqlDataAdapter(Cmd);
                DataTable table = new DataTable();
                adapter.Fill(table);
                md.T_LoginSid = Convert.ToInt32(table.Rows[0]["T_LoginSid"]);
                md.T_LoginSName = table.Rows[0]["T_LoginSName"].ToString();
                md.T_LoginSPwd = table.Rows[0]["T_LoginSPwd"].ToString();
              
                return md;
            }
            catch
            {
                return null;
            }
            finally
            {
                Conn.Close();
            }
        }
    }
}
